﻿@model Inovout.Memberships.Models.MembershipUser
@{
    Layout = "~/Views/Shared/_SignLayout.cshtml";
    ViewBag.Title = "三宝云账户维护"; 
}

<header class="reg_header">
    <img src="~/Styles/Themes/Google/Images/logo_2x.png" />
    <span>
        <a id="account-link-button">@ViewBag.Membership.Name</a>
        <a href='@Url.Action("SignOut", "Account", new { returnUrl = ViewBag.ReturnUrl })'>退出</a>

    </span>
</header>
<div class="link_main w50">
    <h1>三宝云个人账户关联</h1>
    <div class="person_link">
        <div class="wgt">
            <div class="person_link_form w50">
                @Html.ValidationSummary(true)
                @Html.HiddenFor(model => model.Id)
                @{
                    List<AuthenticationClientData> clientdata = new List<AuthenticationClientData>();
                    Inovout.Web.Security.InovoutOAuthClient inovoutOAuthClient = new Inovout.Web.Security.InovoutOAuthClient("inovout");
                    AuthenticationClientData inovoutAuthClentData = new AuthenticationClientData(inovoutOAuthClient, "3cloud", new Dictionary<string, object>());
                    clientdata.Add(inovoutAuthClentData);
                    clientdata.AddRange(OAuthWebSecurity.RegisteredClientData.ToList());
                    foreach (var item in clientdata)
                    {

                        string accountName = null;
                        foreach (var user in ((Inovout.Security.SystemUser)Model.SystemUser).UserCredentials)
                        {
                            if (user.Provider.ToLower() == item.AuthenticationClient.ProviderName)
                            {
                                accountName = accountName + @user.AccountName + "; ";
                            }
                        }
                        string imgpath = "/Images/" + @item.AuthenticationClient.ProviderName + "Link.png";

                    <div class="link-position">
                        <img src="@imgpath" />
                        @if (item.AuthenticationClient.ProviderName.ToLower() == "inovout")
                        {           
                            <span>@accountName</span>
                        }
                        else
                        {
                            <span>@accountName
                                @Html.ActionLink("关联新的" + @item.DisplayName + "账户", "ExtensionalLink", "SystemUser", new { provider = item.AuthenticationClient.ProviderName }, new { @target = "_self" })
                            </span>
                        }
                    </div>               
                    }
                }
            </div>
        </div>
    </div>
</div>

